<?php
session_start();  
//INCLUDE VAR
include("includes/var_global.php");
//INCLUDE FONCTIONS
include("functions/fonctions_DB.php");
include("functions/fonctions_html.php");

// DEBUT CODE
genererHeader('LawResolution');

// Si on a tenté de se connecter
if(isset($_POST['email'])){
	$result = login($_POST['email'], $_POST['passwd']);
	if(!$result){
		// Erreur TODO
		die('probleme de connection');
	} 
	if(isset($_POST['autoConnect']) && $result) {
		setcookie('email', $_POST['email'] , time() + 15*24*3600);
		// criptage need
		setcookie('passwd', $_POST['passwd'] , time() + 15*24*3600);
	}
}

// Verif si connecté
if(isset($_SESSION['email']) AND isset($_SESSION['nom']) AND isset($_SESSION['prenom'])){
	include("modules/connecte.php");
}elseif(isset($_COOKIE['email'])) {
	login($_COOKIE['email'], $_COOKIE['passwd']);
	include("modules/connecte.php");	
}else{
	genererFormConnexion();
	genererMenu();
	genererContenu();
	genererFormContact();
}




genererFooter();

?>